﻿Imports MySql.Data.MySqlClient
Public Class Form4


    Public objCommand As MySqlCommand
    Public Connection As MySqlConnection
    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

connect:

        Dim connectString As String = "Server=localhost;Database=salaria;UserID=root;Password="
        Try

            Connection = New MySqlConnection()
            Connection.ConnectionString = connectString
            Connection.Open()
            Label1.Text = "Connexion à la base de donnée réussi !" + vbNewLine + "Ne pas fermez cette fenêtre"
            Me.Hide()
            Login.Show()
        Catch ex As Exception

            MessageBox.Show("Impossible de se connecter à la base de donnée." + vbNewLine + "Solutions Possibles : " + vbNewLine + "1 - Activer le port 3306 sur windows." + vbNewLine + "2 - Autoriser le port 3306 sur votre routeur ou box.", "Base de donnée", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
            If DialogResult.Retry Then
                GoTo connect
            Else
                Me.Close()
            End If
            Return
        End Try
    End Sub
End Class